package com.eliza.library.ui.compose

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.eliza.library.ui.inter.IBaseRoute



@Composable
fun NavRouteColumn(navController: NavController, entries: List<IBaseRoute>) {
    Column(
        modifier = Modifier.verticalScroll(rememberScrollState()),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        entries.forEachIndexed { _, route ->
            Row(
                modifier = Modifier
                    .fillMaxWidth() //导航参数
                    .clickable {
                        navController.navigate(route.title)
                    },
                horizontalArrangement = Arrangement.spacedBy(15.dp),
//                verticalAlignment = Alignment.Bottom
            ) {
                Icon(
                    route.imageVector,
                    contentDescription = null,
                    modifier = Modifier
                        .padding(20.dp, 6.dp)
                        .size(40.dp),
                    tint = Color.Black
                )
                Text(
                    modifier = Modifier.padding(5.dp),
                    color = Color.Black,
                    text = route.title,
                    fontWeight = FontWeight.Bold,
                    fontSize = 20.sp,
                    maxLines = 1,
                )
            }

        }
    }
}

@Composable
fun NavRouteRow(navController: NavController, entries: List<IBaseRoute>) {
    Row(
        modifier = Modifier
            .verticalScroll(rememberScrollState())
            .fillMaxWidth(1F),
        horizontalArrangement = Arrangement.SpaceEvenly,
        verticalAlignment = Alignment.CenterVertically,
    ) {
        entries.forEachIndexed { index, route ->
            TextButton(
                onClick = {
                    navController.navigate(
                        route.title
                    )
                },
            ) {
                Text(text = route.title)
            }
        }
    }
}

